﻿using System;
using System.ComponentModel;

namespace Useful
{
    public abstract class BasePropertyDescriptor : PropertyDescriptor
    {
        protected BasePropertyDescriptor(string header, string propName)
            : base(propName, new Attribute[] { new DisplayNameAttribute(header) })
        {
        }

        public override bool CanResetValue(object component)
        {
            throw new NotImplementedException();
        }

        public override Type ComponentType
        {
            get { throw new NotImplementedException(); }
        }

        protected abstract object GetValueCore(object component);
        protected abstract Type GetPropertyTypeCore();
        protected abstract bool GetIsReadOnlyCore();

        public override object GetValue(object component)
        {
            return GetValueCore(component);
        }

        public override bool IsReadOnly
        {
            get
            {
                return GetIsReadOnlyCore();
            }
        }

        public override Type PropertyType
        {
            get
            {
                return GetPropertyTypeCore();
            }
        }

        public override void ResetValue(object component)
        {
            throw new NotImplementedException();
        }

        public override void SetValue(object component, object value)
        {
            throw new NotImplementedException();
        }

        public override bool ShouldSerializeValue(object component)
        {
            throw new NotImplementedException();
        }
    }
}
